package org.demo.test;


import org.demo.nio.NioTest;
import org.demo.url.BrokenPointDownload;
import org.demo.url.MutilDownload;

import java.io.IOException;
import java.net.MalformedURLException;

public class Main {

    public static void main(String[] args) throws Exception {
        //InetAddressDemo.getAddress();
        /*try {
            String hostName=InetAddress.getLocalHost().getHostName();
            System.out.println(InetAddress.getLocalHost().getHostAddress());
            System.out.println(hostName);
            InetAddressDemo.getAddress(hostName);
            InetAddressDemo.getAddress("172.28.57.1");
        } catch (UnknownHostException e) {
            e.printStackTrace();
        }
        InetAddressDemo.getAddress("www.baidu.com");
        InetAddressDemo.getAddress("www.aaaaa.aaaaaa");*/

        /*new Thread(new Runnable() {
            @Override
            public void run() {
                Server.start();
            }
        }).start();
        new Thread(new Runnable() {
            @Override
            public void run() {
               Client client= new Client();
                client.start();
                client.send("消息1");
                try {
                    Thread.sleep(200);
                } catch (InterruptedException e) {
                    e.printStackTrace();
                }
                client.send("消息2");
                client.close();
            }
        }).start();*/
//http://musicdata.baidu.com/data2/lrc/238665983/238665983.lrc
        //http://wangshuo.jb51.net:81/201206/books/javarumen_jb51net.rar
        /*try {
            MutilDownload downUtil = new MutilDownload("http://musicdata.baidu.com/data2/lrc/238665983/238665983.lrc", 3, "D:\\238665983.lrc");
            downUtil.download();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }

        try {
            MutilDownload downUtil = new MutilDownload("http://wangshuo.jb51.net:81/201206/books/javarumen_jb51net.rar", 3, "D:\\javarumen_jb51net.rar");
            downUtil.download();
        } catch (MalformedURLException e) {
            e.printStackTrace();
        } catch (IOException e) {
            e.printStackTrace();
        }*/
        //BrokenPointDownload download=new BrokenPointDownload("http://wangshuo.jb51.net:81/201206/books/javarumen_jb51net.rar","D:\\javarumen_jb51net2.rar");
        //BrokenPointDownload download=new BrokenPointDownload("http://down-www.newasp.net/soft/soft1/javarmjd_pdf.zip","D:\\javarmjd_pdf.zip");
        //设置是否终止下载，为了测试断点续传
        //download.setIsContinue(true);
        //download.download();
        //System.out.println("终止了下载................");
        //Thread.sleep(5000);
        /*System.out.println("继续了下载................");
        download.setIsContinue(true);
        download.download();*/

        //MutilDown.test();
        /*FTPClient ftpClient =null;
        try {
            ftpClient = FTPUtils.create("ftptest", "aaa111", "127.0.0.1", 21);
            System.out.println(FTPUtils.removeDirectory(ftpClient, "aaa/bbb/cccc"));
        } catch (IOException e) {
            System.out.println("错误消息:"+e);
            return;
        }*/
        //NioTest.simpleReactorTest();
        //NioTest.multiThreadReactorTest();
        NioTest.multiReactorTest();
        System.out.println("运行完成................");
    }
}



